package modelo

import java.util.Random
import java.util.List
import java.util.ArrayList
import exepciones.perdisteException
import org.uqbar.commons.model.UserException

class Zombie extends Atacante implements Cloneable {
	@Property int resBase
	
	new(){
		resBase=resistencia
	}
	
	def void atacar(Terreno terreno, Observer obs){
		if (this.resistencia <= 0)
			throw new UserException("El zombie esta muerto! no puede atacar")
		this.ataca(terreno.dameLaUltimaPlanta(obs),obs)
	}
	
	override cambiaObjetivo(Atacante planta, Observer obs) {
		obs.noTengoMasPlanta(this)
	}
	
	override postMorten(Observer obs) {
		val int rnd = new Random().nextInt(100)
		if(rnd <50) if(rnd < 13){ this.daPlanta(obs)} else this.daPremio(obs)
	}
	
	def void daPremio(Observer obs){
		val int rnd = new Random().nextInt(resBase)
		obs.elJugadorGanaDinero(rnd)
	}
	def void daPlanta(Observer obs){
		obs.elJugadorGanaUnaPlanta
	}

	def clonate(){
		return (this.clone as Zombie)
		
	}

	
	

}